<!DOCTYPE html>
<html>
{include file="Login/header" /}
<style>
    img{width: 200px}
    span{color: #cc181b}
</style>
<body class="login" mycollectionplug="bind" style="background: #44AAFF">
<div class="login_out"><a href="{:url('index/outLogin')}">切换其他账号登录>></a> </div>
    <div class="company_boder">
        <div class="company_m" >
            <div class="company_title">
                <div style="font-size: 26px;  height: 40px;  ">企业信息认证</div>
                <div class="col-sm-12 text-center" style="font-size: 12px;color: rgba(204,37,41,1)">您也可以通过发送资料至xups@8518.com完成企业认证，下载资料模板</div>
            </div>
            <br/> <br/>
            <form action="{:url('index/addCompany')}" method="post" id="from">
                <h2><span>*</span>企业名称：</h2>
                <label>
                    <input type="text" name="company_name" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>营业执照(三证统一号)：</h2>
                <label>
                    <input type="text" name="license_no" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>营业执照：</h2>
                <label>
                   <div id="license_file"></div>
                </label>
                <h2><span>*</span>组织机构代码证(三证统一就传营业执照)：</h2>
                <label>
                    <div id="org_no"></div>
                </label>
                <h2><span>*</span>税务登记证(三证统一就传营业执照)：</h2>
                <label>
                    <div id="tax_no"></div>
                </label>

                <h2><span>*</span>营业执照所在地：</h2>
                <label>
                    <input type="text" name="license_address" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>执照过期日：</h2>
                <label>
                    <input type="text" name="license_expire_date" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>营业范围：</h2>
                <label>
                   <textarea  name="business_scope"  rows="5"></textarea>
                </label>
                <h2><span>*</span>联系电话：</h2>
                <label>
                    <input type="text" name="telephone" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>组织机构代码：</h2>
                <label>
                    <input type="text" name="organization_no" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>企业简介：</h2>
                <label>
                    <textarea  name="summary"  rows="5" class="textarea"></textarea>
                </label>
                <h2>企业网址：</h2>
                <label>
                    <input type="text" name="website" class="txt_input txt_input2"   value="" placeholder="">
                </label>
                <h2><span>*</span>企业地址：</h2>
                <label>
                    <input type="text" name="address" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>企业法人：</h2>
                <label>
                    <input type="text" name="legal_person" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>法人手机号：</h2>
                <label>
                    <input type="text" name="legal_person_phone" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>法人身份证号码：</h2>
                <label>
                    <input type="text" name="cert_no" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>身份证正面：</h2>
                <label>
                    <div id="front_card"></div>
                </label>
                <h2><span>*</span>身份证反面：</h2>
                <label>
                    <div id="back_card"></div>
                </label>
                <h2><span>*</span>开户行：</h2>
                <label>
                    <select data-val="开户行"  class="select" name="bank_code">
                        <?php foreach(\think\Config::get('bank_list') as $key=>$value){  ?>
                        <option value="{$key}">{$value}</option>
                        <?php  } ?>
                    </select>
                </label>
                <h2><span>*</span>开户卡号：</h2>
                <label>
                    <input type="text" name="bank_account_no" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>开户省市：</h2>
                <label>
                    <select name="province" id="province" class="txt_input txt_input2"  ></select>
                </label>
                <label>
                    <select  name="city" id="city"  class="txt_input txt_input2" ></select>
                </label>
                <h2><span>*</span>开户支行名称：</h2>
                <label>
                    <input type="text" name="bank_branch" class="txt_input txt_input2" required  value="" placeholder="">
                </label>
                <h2><span>*</span>开户许可证：</h2>
                <label>
                    <div id="open_account_no"></div>
                </label>
                <label>
                    <div class="col-sm-12 text-center" style="width: 420px;margin: 0 auto;">
                        <button id="submit"  type="button" class="btn btn-success">提交</button>
                    </div>
                </label>
            </form>
        </div>
    </div>
</body>

{include file="Login/footer" /}

<script>
    dsy._init_area(['province','city']);
    $(document).ready(function(){

        toUpYun.init('chaoebao/merchant/{$user_id}/','front_card','image/jpeg','jpg');
        toUpYun.init('chaoebao/merchant/{$user_id}/','back_card','image/jpeg','jpg');
        toUpYun.init('chaoebao/merchant/{$user_id}/','license_file','image/jpeg','jpg');
        toUpYun.init('chaoebao/merchant/{$user_id}/','org_no','image/jpeg','jpg');
        toUpYun.init('chaoebao/merchant/{$user_id}/','tax_no','image/jpeg','jpg');
        toUpYun.init('chaoebao/merchant/{$user_id}/','open_account_no','image/jpeg','jpg');


        //文本框剩余字数提醒
        $("textarea").change(function () {
            var lengths = $(this).val().length;
            var surplus =255 -lengths;
            $(this).parent().find(".count").html(surplus);
        });

    });

    $("#submit").click(function () {
        var _Test = true;
        $("#from .required").each(function () {
            if($(this).val()=="")
                alert($(this).data("val")+'请填写')
                $(this).focus();
                _Test = false;
                return false;
            });
        if(_Test == true)
        {
            var data = $("#from").serialize();
            toAjax("{:url('user/setCompanyInfo')}",
                data,"GET",
                function(rs){
                    console.log(rs);

                    if(rs.code == 1){
                        console.log(rs.message);
                        if(rs.data.url != null){
                            window.location = rs.data.url;
                        }
                        else{
                           alert(rs.message);
                            //history.go(0);
                        }
                    }

                    if(rs.code == 0){
                        window.location = rs.data.url;
                    }
                },
                false,false,this);
        }
        });


    //tab-pane

    //验证身份证号码是否正确
    $(".card").change(function () {
        var card = jQuery(".card").val();
        if(card==''){
            alert('身份证号码不得为空');return;
        }
        if(isCardNo($.trim($('.card').val())) == false) {
            alert('身份证号码不合规')
            $(this).val();
            $('#identity').focus();
        }
    })

    //身份证
    function isCardNo(card) {
        var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        return pattern.test(card);
    }
    //验证手机号
    $(".phone").change(function () {
        var phone = jQuery(".phone").val();
        var flag = false;
        var message = "";
        var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
        if(phone.length !=11){
            message = "请输入有效的手机号码！";
        }else if(!myreg.test(phone)){
            message = "请输入有效的手机号码！";
        }else{
            flag = true;
        }
        if(!flag){
            jQuery(".phone").val('');
            alert(message);
        }else{
        }
        return flag;
    });






</script>
